<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="app">
        <counter :num1="num" :title="0" @incr1="incr()"></counter>
        <!--<counter></counter>
        <counter></counter>-->
    </div>
</body>
<script src="node_modules/vue/dist/vue.js"></script>
<script>

    Vue.component("counter", {
        template: "<div><button @click='subIncr'>点我呀，点我加1。{{num1}}-{{title}}</button><span></span></div>",
        props: {
            num1: {
                type: Number,
                default: 0
            },
            title: {
                type: Number
            }
        },
        methods: {

            subIncr(){
                this.$emit("incr1");
            }
        }
    })

    const app = new Vue({
        el: "#app",
        data: {
            num: 0
        },
        methods: {
            incr(){
                this.num++;
            }
        }
    })

</script>
</html>